home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- '''Test script for popen2.py
- Christian Tismer
- '''
- import os
- import sys
- from test.test_support import TestSkipped
-
- def main():
- print 'Test popen2 module:'
- if (sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos') and __name__ != '__main__':
- raise TestSkipped, "popen2() doesn't work during import on " + sys.platform
-
-
- try:
- popen = popen
- import os
- except ImportError:
- fork = fork
- import os
-
- import popen2
- popen2._test()
-
-
- def _test():
- print 'Testing os module:'
- import popen2
- cmd = 'cat'
- teststr = 'ab cd\n'
- if os.name == 'nt':
- cmd = 'more'
-
- expected = teststr.strip()
- print 'testing popen2...'
- (w, r) = os.popen2(cmd)
- w.write(teststr)
- w.close()
- got = r.read()
- if got.strip() != expected:
- raise ValueError('wrote %r read %r' % (teststr, got))
-
- print 'testing popen3...'
-
- try:
- (w, r, e) = os.popen3([
- cmd])
- except:
- (w, r, e) = os.popen3(cmd)
-
- w.write(teststr)
- w.close()
- got = r.read()
- if got.strip() != expected:
- raise ValueError('wrote %r read %r' % (teststr, got))
-
- got = e.read()
- if got:
- raise ValueError('unexpected %r on stderr' % (got,))
-
- for inst in popen2._active[:]:
- inst.wait()
-
- if popen2._active:
- raise ValueError('_active not empty')
-
- print 'All OK'
-
- main()
- _test()
-